
var fs = require('fs');
function index (req, res, next){
	//console.log("index is " + __dirname);
	fs.readFile('./management/view/main.html', function(err, html){
		if(err){
			console.log(err);
		}else{
		//	console.log("index is " + html);
			res.setHeader('Content-Type', 'text/html');
		    res.writeHead(200);
			res.end(html);
		}
	});
	
	return next;
}


function JS(req, res, next){
	console.log(req.url);
	fs.readFile('./management' + req.url, function(err, html){
		if(err){
			console.log(err);
		}else{
			res.setHeader('Content-Type', 'text/javascript');
		    res.writeHead(200);
			res.end(html);
		}
	});
	return next;
}

function CSS(req, res, next){
	console.log(req.url);
	fs.readFile('./management' + req.url, function(err, html){
		if(err){
			console.log(err);
		}else{
			res.setHeader('Content-Type', 'text/css');
		    res.writeHead(200);
			res.end(html);
		}
	});
	return next;
}

function IMAGES(req, res, next){
	console.log(req.url);
	fs.readFile('./management' + req.url, function(err, html){
		if(err){
			console.log(err);
		}else{
			res.setHeader('Content-Type', 'image/png');
		    res.writeHead(200);
			res.end(html);
		}
	});
	return next;
}
exports.services = [ index , JS, CSS, IMAGES] ;